<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>工厂模式</title>
</head>
<body>
<h6>工厂模式：通过工厂方法创建实例对象</h6>
<script>
    class Car {
        constructor(name) {
            this.name = name
        }
        getCarName() {
            console.log(`汽车品牌：${this.name}`)
        }
    }
    class ProduceCar {
        static creatCar(carName) {
            return new Car(carName)
        }
    }
    const car1 = ProduceCar.creatCar('东风日产');
    const car2 = ProduceCar.creatCar('东风本田');
    car1.getCarName()
    car2.getCarName()
</script>
</body>
</html>
